package api

import (
"context"

bm "github.com/go-kratos/kratos/pkg/net/http/blademaster"
"github.com/go-kratos/kratos/pkg/net/http/blademaster/binding"
)
import google_protobuf1 "google.golang.org/protobuf/types/known/emptypb"

// to suppressed 'imported but not used warning'
var _ *bm.Context
var _ context.Context
var _ binding.StructValidator

var PathDemoPing = "/MobilePackage.service.v1.Demo/Ping"
var PathDemoSayHello = "/MobilePackage.service.v1.Demo/SayHello"
var PathDemoSayHelloURL = "/demo/say_hello"
var PathDemoRecommend = "/recommend"
var PathDemoDeal = "/deal"
var PathDemoCheck = "/check"

// DemoBMServer is the server API for Demo service.
type DemoBMServer interface {
	Ping(ctx context.Context, req *google_protobuf1.Empty) (resp *google_protobuf1.Empty, err error)

	SayHello(ctx context.Context, req *HelloReq) (resp *google_protobuf1.Empty, err error)

	SayHelloURL(ctx context.Context, req *HelloReq) (resp *HelloResp, err error)

	// 推荐优惠活动
	Recommend(ctx context.Context, req *RecommendReq) (resp *RecommendResp, err error)

	// 优惠活动办理
	Deal(ctx context.Context, req *DealReq) (resp *DealResp, err error)

	// 个人办理优惠活动核查
	Check(ctx context.Context, req *CheckReq) (resp *CheckResp, err error)
}

var DemoSvc DemoBMServer

func demoPing(c *bm.Context) {
	p := new(google_protobuf1.Empty)
	if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
		return
	}
	resp, err := DemoSvc.Ping(c, p)
	c.JSON(resp, err)
}

func demoSayHello(c *bm.Context) {
	p := new(HelloReq)
	if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
		return
	}
	resp, err := DemoSvc.SayHello(c, p)
	c.JSON(resp, err)
}

func demoSayHelloURL(c *bm.Context) {
	p := new(HelloReq)
	if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
		return
	}
	resp, err := DemoSvc.SayHelloURL(c, p)
	c.JSON(resp, err)
}

func demoRecommend(c *bm.Context) {
	p := new(RecommendReq)
	if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
		return
	}
	resp, err := DemoSvc.Recommend(c, p)
	c.JSON(resp, err)
}

func demoDeal(c *bm.Context) {
	p := new(DealReq)
	if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
		return
	}
	resp, err := DemoSvc.Deal(c, p)
	c.JSON(resp, err)
}

func demoCheck(c *bm.Context) {
	p := new(CheckReq)
	if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
		return
	}
	resp, err := DemoSvc.Check(c, p)
	c.JSON(resp, err)
}

// RegisterDemoBMServer Register the blademaster route
func RegisterDemoBMServer(e *bm.Engine, server DemoBMServer) {
	DemoSvc = server
	e.GET("/MobilePackage.service.v1.Demo/Ping", demoPing)
	e.GET("/MobilePackage.service.v1.Demo/SayHello", demoSayHello)
	e.GET("/demo/say_hello", demoSayHelloURL)
	e.GET("/recommend", demoRecommend)
	e.POST("/deal", demoDeal)
	e.GET("/check", demoCheck)
}
